<?php 
$facebookAuthUrl = My\Auth\Adapter\Facebook::getAuthorizationUrl();
$twitterAuthUrl = \My\Auth\Adapter\Twitter::getAuthorizationUrl();
$googleAuthUrl = My\Auth\Adapter\Google::getAuthorizationUrl();
?>
<li class="login">
    <div id="login">
        <div class="left-log">
            <form action="<?php echo $this->baseUrl();?>/login" method="post">
            <div class="error" style="color:red"></div>
            <p><input type="text" value="Email" name="email" onblur="if (this.value=='') this.value='Email';" onfocus="if (this.value=='Email') this.value='';" class="us"/></p>
            <p><input type="password" value="Password" name="password" onblur="if (this.value=='') this.value='Password';" onfocus="if (this.value=='Password') this.value='';" class="pw"/></p>
                <p class="bot">
                    <input type="checkbox" id="checkbox-1-1" class="regular-checkbox" />
                    <label for="checkbox-1-1"></label><span class="remer">Remember me</span> 
                    <a href="<?php echo $this->baseUrl();?>/forgot-password" class="forgot">Forgot password</a>
                </p>
                <p class="need">
                    <a href="<?php echo $this->baseUrl();?>/register" title="">Need an account?<span>Sign Up</span></a> 
                    <input class="submitlogin" type="button" value=""/>
                </p>
            </form>
        </div>
        <div class="right-log">
            <h5>Sign In using social network</h5>
            <p>Build your own personal story stream, participate in discussions, easily share your favorite stories, and connect with what your friends are sharing.</p>
            <p>Just select your favorite social network to get started.</p>
            <p class="openid">
                <a href="<?php echo $facebookAuthUrl ?>" class="fb">FB</a>
                <a href="/user/connect-twitter" class="tw">TW</a>
                <a href="<?php echo $googleAuthUrl ?>" class="gg">GG</a>
            </p>
        </div>
        <div class="clearfix"></div>
    </div>
</li>
<script type="text/javascript">
$(document).ready(function(){
    $('.submitlogin').click(function(){
        var baseUrl = '<?php echo $this->baseUrl();?>';
        var email = $('input[name=email]').val();
        var pass = $('input[name=password]').val();
        var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;

        if(pass == 'Password' || email == 'Email'){
            $('.error').html('<p>Email or Password is not null</p>');
            return false;
        }
        if ( !emailReg.test( email ) ) {
            $('.error').html('<p>Invalid email</p>');
            return false;
        }
        $.ajax({
            type: "POST",
            url: baseUrl + "/user/check-login",
            data: {
            	email: email,
            	password: pass
            },
            success: function(response) {
                if(response == 1) window.location.href = baseUrl;
                else $('.error').html('<p>Email or Password incorrect</p>');
            }
        });
    });

    return true;
});
</script>
                